﻿
using Dapper;
using hdb;
using hentity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace hwms {
    //一个任务完成则不允许执行删除任务
    public class WmsWhEngine :GkTransaction {
  
        public int locId;
        public long areaId;
        public int activeStatus;
        //入库完成反馈
        protected override TransRes Execute(IDbConnection conn, IDbTransaction tran)
        {
            CoreWhLoc loc = conn.GetById<CoreWhLoc>(locId ,tran);
            int moveGroup = loc.moveGroup;
            long oldAreaId = loc.areaId;
            String sql = "update Core_Wh_Loc set area_Id= @areaId,  Active_Status = @activeStatus where id=@locId ";
            if( activeStatus == -1 ) {
                sql = "update Core_Wh_Loc set area_Id= @areaId   where id=@locId ";
            } 

            conn.Execute(sql ,new { locId ,areaId,activeStatus }) ;

            if( areaId != oldAreaId ) {//换库区了
                CoreUtil.updateMoveGroup(conn ,tran ,oldAreaId ,moveGroup ,loc.craneId);
            }
            CoreUtil.updateMoveGroup(conn ,tran ,areaId ,moveGroup ,loc.craneId);
            return new TransRes();
        }
  



    }
}
